package org.idtem.utils.configuration;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.idtem.utils.constants.Constants;


public class Configuracion {
	
	/**
	 * Permite leer el valor de una clave de un archivo de configuracion.
	 * @param key
	 * @return
	 */
	public static String getString(String key, String file){
		Properties properties = new Properties();
		InputStream propIn;
		String retorno = null;
		try {
			File ffile = new File(file);
			propIn = new FileInputStream(ffile);
			properties.load(propIn);
			retorno = properties.getProperty(key).trim();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return retorno;
	}
	
	
	public static int getInt(String key, String file){
		String valor = Configuracion.getString(key, file);
		return Integer.parseInt(valor);
	}
	
	public static boolean getBoolean(String key, String file){
		String valor = Configuracion.getString(key, file);
		return Boolean.parseBoolean(valor);
	}
	
	public static double getDouble(String key, String file){
		String valor = Configuracion.getString(key, file);
		return Double.parseDouble(valor);
	}
		
	
}
